[?php include_stylesheets_for_form($form) ?]
[?php include_javascripts_for_form($form) ?]
[?php use_helper('Form', 'Javascript') ?]

<div class="sf_admin_form">
  [?php echo form_tag_for($form, (isset($form_action)? '<?php echo $this->params['route_prefix'] ?>/'.$form_action : '@<?php echo $this->params['route_prefix'] ?>'), array('id' => 'sf_admin_edit_form', 'onsubmit' => "needs_to_confirm = false; return disableFurtherSubmit(this)")) ?]
    [?php echo $form->renderHiddenFields() ?]
    [?php echo input_hidden_tag('form_class', get_class($form)) ?]
    [?php echo input_hidden_tag('id', $form->getObject()->getId()) ?]
    [?php echo input_hidden_tag('batch_c', $sf_request->getParameter('batch_c')) ?]

    [?php if ($form->hasGlobalErrors()): ?]
      [?php echo $form->renderGlobalErrors() ?]
    [?php endif; ?]

    [?php $iterateOver = method_exists($form, 'getFieldsets')? $form->getFieldsets() : $form ?]
    [?php foreach ($iterateOver as $fieldset => $fields): ?]
      [?php include_partial('<?php echo $this->getModuleName() ?>/form_fieldset', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>, 'form' => $form, 'fields' => $fields, 'fieldset' => $fieldset)) ?]
    [?php endforeach; ?]

    [?php include_partial('<?php echo $this->getModuleName() ?>/cart_form_actions', array('<?php echo $this->getSingularName() ?>' => $<?php echo $this->getSingularName() ?>, 'form' => $form, 'configuration' => $configuration, 'helper' => $helper)) ?]
    [?php echo method_exists($form, 'getChildPostRenderJavascripts')? javascript_tag($form->getChildPostRenderJavascripts()) : '' ?]
  </form>
</div>

<?php if (isset($this->params['confirm_on_close']) && $this->params['confirm_on_close']): ?>
<script type="text/javascript">
//<![CDATA[
  var needs_to_confirm = true;

  window.onbeforeunload = function (event) {
    if (needs_to_confirm)
    {
      return "[?php echo __('Are you sure you want to close this window? By doing so, any unsaved work will be lost.', array(), 'sf_admin') ?]";
    }
  };
//]]>
</script>
<?php endif; ?>
